const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/bilibili');

// once 事件回调函数只执行一次
mongoose.connection.once('connected', () => {
    console.log('Mongoose connection open to bilibili');
});
mongoose.connection.on('error', (err) => {
    console.log('Mongoose connection error: ' + err);
});
mongoose.connection.on('disconnected', () => {
    console.log('Mongoose connection disconnected');
});


setTimeout(() => {
    mongoose.disconnect();
}, 1000 * 5);